<?php
class Account_Lib_Remote_Invoker_WriteService
{
    /**
     * @var Account_Lib_Service_Write_AccountManagementService
     */
    protected $_accountManagementWriteService;
    
    /**
     * @var Account_Lib_Service_Write_AuthService
     */
    protected $_authWriteService;
    
    /**
     * @var Account_Lib_Service_Write_ProductsManagementService
     */
    protected $_productsManagementWriteService;

    /**
     * @param Account_Lib_Service_Write_AccountManagementService $accountManagementWriteService
     * @param Account_Lib_Service_Write_AuthService $authWriteService
     * @param Account_Lib_Service_Write_ProductsManagementService $productsManagementWriteService
     */
    public function __construct(
        Account_Lib_Service_Write_AccountManagementService $accountManagementWriteService,
        Account_Lib_Service_Write_AuthService $authWriteService,
        Account_Lib_Service_Write_ProductsManagementService $productsManagementWriteService
    )
    {
        $this->_accountManagementWriteService = $accountManagementWriteService;        
        $this->_authWriteService = $authWriteService;        
        $this->_productsManagementWriteService = $productsManagementWriteService;       
    }
    
    /**
     * Create new account
     * 
     * $ownerInformation keys:
     *  - string $firstName
     *  - string $lastName
     *  - string $dateOfBirth
     *  - string $gender
     *  - string $nickName
     *  - string $mobileNumber
     *  - string $homeNumber
     *  - string $additionalInformation
     *  
     * $deliveryInformation keys:
     *  - string $country
     *  - string $city
     *  - string $postCode
     *  - string $street
     *  - string $houseNumber
     *  - string $secondAddressLine
     *  - string $thirdAddressLine
     *  - string $additionalInformation 
     *  
     * $settings keys:
     *  - locale keys:
     *    - array country 
     *       - string code
     *       - string title
     *    - array language 
     *       - string code
     *       - string title
     * 
     * @param string $email
     * @param string $password
     * @param string $passwordAgain
     * @param array $ownerInformation
     * @param array $deliveryInformation
     * @param array $settings
     * @param boolean $isAutoGenerated
     * 
     * @return void
     */
    public function setupAccount(
        $email, 
        $password, 
        $passwordAgain, 
        array $ownerInformation = array(),
        array $deliveryInformation = array(),
        array $settings = array(),
        $isAutoGenerated = false
    )
    {
        $this->_accountManagementWriteService->createNewAccount(
            $email, 
            $password, 
            $passwordAgain, 
            $ownerInformation, 
            $deliveryInformation, 
            $settings,
            $isAutoGenerated
        );
    }
         
	/**
     * Activate account by confirmg primary email address
     * 
     * @param string $email
     * @param string $activationKey
     * 
     * @return void
     */
    public function activateAccount($email, $activationKey)
    {
        $this->_authWriteService->activateAccount($email, $activationKey);
    }
         
	/**
     * Login
     * 
     * @param string $email
     * @param string $password
     * 
     * @return void
     */
    public function login($email, $password)
    {
        $this->_authWriteService->login($email, $password);
    }
    
    /**
     * Logout
     * 
     * @param string $email
     */
    public function logout($email)
    {
        $this->_authWriteService->logout($email);
    }
    
    /**
     * Remind password
     * 
     * @param string $emailAddress
     */
    public function remindPassword($email)
    { 
        $this->_accountManagementWriteService->remindPassword($email);
    }
    
    /**
     * @param string $emailAddress
     */
    public function remindActivationKey($emailAddress)
    { 
        $this->_accountManagementWriteService->remindActivationKey($emailAddress);
    }
    
    /**
     * Change password
     * 
     * @param string $emailAddress
     * @param string $password
     */
    public function changePassword($email, $password)
    { 
        $this->_accountManagementWriteService->changePassword($email, $password);
    }
    
    /**
     * Add products to account
     * 
     * @param string $email
     * @param array $productsInformation
     */
    public function addProductsToAccount($email, array $productsInformation)
    {
        $this->_productsManagementWriteService->addNewProductsInAccount(
            $email, 
            $productsInformation
        );       
    }
}